﻿using System;
using System.Data;

namespace SimpleService.ORM
{

    public class Delete
    {
        public PersistenceObject _table;

        public Delete(PersistenceObject _table) { this._table = _table; }	

        public bool Execution(string key)
        {

            _table.ColsName = PersistenceUtility.ColumnsName(_table.datatable); 

            string SQLstr = ORMConfig.delete;

            SQLstr = SQLstr.Replace("__table__", _table._TableName);
            SQLstr = SQLstr.Replace("__key__", _table.ColsName[0]);
            SQLstr = SQLstr.Replace("__val__", _table.KeyType(key));

            return SqlOperator.ExecuteNonQuery(SQLstr, _table._connection);
        }

    }
}
